package cl.portal.escolares.json;

import net.sf.json.JSONArray;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import cl.portal.escolares.DAO.DAOCurso;

import com.opensymphony.xwork2.ActionSupport;

public class JSONCursos extends ActionSupport {
	private static final long serialVersionUID = 1L;
	private static Log _log = LogFactory.getLog(JSONCursos.class);

	private Long colegioId;
	private JSONArray jCursos;

	public String execute() throws Exception {
		try {
			jCursos = JSONArray.fromObject(DAOCurso.list(colegioId, true));
			_log.info("colegioId=" + getColegioId());
			_log.info("size=" + jCursos.size());
			setjCursos(jCursos);
			System.out.println(jCursos);
			return "success";
		} catch (Exception e) {
			_log.info(e);
			return "error";
		}
	}

	public Long getColegioId() {
		return colegioId;
	}

	public void setColegioId(Long colegioId) {
		this.colegioId = colegioId;
	}

	public JSONArray getjCursos() {
		return jCursos;
	}

	public void setjCursos(JSONArray jCursos) {
		this.jCursos = jCursos;
	}

}
